package cn.tedu.sp02.service;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.sp01.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName ItemServiceImpl
 * @Description:类描述
 * @Author Tedu
 * @Date 2021/6/22 11:44
 * @Version V1.0
 **/
@Service
@Slf4j
public class ItemServiceImpl implements ItemService {

    //获取订单的商品列表
    @Override
    public List<Item> getItems(String orderId) {
        log.info("获取商品列表,orderId= "+orderId);
        ArrayList<Item> items = new ArrayList<>();
        items.add(new Item(1,"商品1",1));
        items.add(new Item(2,"商品2",3));
        items.add(new Item(3,"商品3",5));
        items.add(new Item(4,"商品4",7));
        items.add(new Item(5,"商品5",9));

        return items;
    }

    @Override
    public void decreaseNumber(List<Item> items) {
        //items.for快捷方式
        for (Item item : items) {
                log.info("减少库存: "+item);
        }

    }
}
